<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Person (name,age) {
            this.name = name 
            this.age = age
        }
        Person.prototype.eat = function (){
            console.log(this.name + '——我在吃饭')
        }
        Person.prototype.sleep = function (){
            console.log(this.name + '——我在睡觉')
        }
        Person.prototype.play = function (){
            console.log(this.name + '——我在玩游戏')
        }
        function createnew (name ,age) {
            const o ={}
            Person.call(o,name,age)
            o.__proto__ = Person.prototype
            return o 
        }
        const p = new Person('王建伟',22)
        const p1 = new Person('wdawd',222)
        const p2 = createnew('zhaaa',33)
        p.eat()
        p1.play()
        p2.sleep()
    </script>
</body>
</html>